import 'package:earclean/app/config/colors.dart';
import 'package:earclean/app/modules/widget/app_bar_widget.dart';
import 'package:earclean/app/modules/widget/login_button.dart';
import 'package:earclean/app/request/request_main.dart';
import 'package:earclean/app/routes/app_pages.dart';
import 'package:earclean/app/util/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import '../controllers/zhuxiao_controller.dart';

class ZhuxiaoView extends GetView<ZhuxiaoController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const AppBarWidget(
          backgroundColor: ColorConfig.white, titleStr: '注销账号'),
      body: Column(
        children: [
          SizedBox(height: 20),
          Obx(() => Html(data: controller.tip.value)),
          SizedBox(height: 1.sw),
          Container(
            width: 1.sw,
            margin: EdgeInsets.symmetric(horizontal: 18.w),
            child: LoginButton(
              "确认注销",
              enable: true,
              onPressed: () async {
                dynamic mobile = await box.read("mobile");
                Map? m = await RequestMain.postUrl({
                  "cancel_member": mobile,
                });
                if (m.isNotEmpty && m['code'].toString() == "200") {
                  EasyLoading.showToast('注销成功');
                  await box.remove('key');
                  await box.remove('kefu');
                  await box.remove('tab');
                  Get.offAllNamed(Routes.LOGIN);
                }
              },
            ),
          )
        ],
      ),
    );
  }
}
